home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1996 July / Macworld (1996-07).dmg / For your System Folder / Sound Manager 3.2a2 / Sound.h < prev    next >
Text File  |  1995-11-24  |  25KB  |  698 lines

  1. /*
  2.      File:        Sound.h
  3.  
  4.      Contains:    Sound Manager Interfaces.
  5.  
  6.      Version:    ETO
  7.  
  8.      DRI:        Jim Reekes
  9.  
  10.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  11.                  All rights reserved.
  12.  
  13.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  14.                  stack.  Include the file and version information (from above)
  15.                  in the problem description and send to:
  16.                      Internet:    apple.bugs@applelink.apple.com
  17.                      AppleLink:    APPLE.BUGS
  18.  
  19. */
  20.  
  21. #ifndef __SOUND__
  22. #define __SOUND__
  23.  
  24.  
  25. #ifndef __TYPES__
  26. #include <Types.h>
  27. #endif
  28. /*    #include <ConditionalMacros.h>                                */
  29.  
  30. #ifndef __COMPONENTS__
  31. #include <Components.h>
  32. #endif
  33. /*    #include <MixedMode.h>                                        */
  34.  
  35. #ifndef __MIXEDMODE__
  36. #include <MixedMode.h>
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_ALIGN_SUPPORTED
  44. #pragma options align=mac68k
  45. #endif
  46.  
  47. #if PRAGMA_IMPORT_SUPPORTED
  48. #pragma import on
  49. #endif
  50.  
  51.  
  52.  
  53. /*
  54.                         * * *  N O T E  * * *
  55.  
  56.     This file has been updated to include Sound Manager 3.2 interfaces.
  57.  
  58.     Some of the Sound Manager 3.0 interfaces were not put into the InterfaceLib
  59.     that originally shipped with the PowerMacs. These missing functions and the
  60.     new 3.2 interfaces have been released in the SoundLib library for PowerPC
  61.     developers to link with. The runtime library for these functions are
  62.     installed by Sound Manager 3.2. The following functions are found in SoundLib.
  63.  
  64.         GetCompressionInfo(), GetSoundPreference(), SetSoundPreference(),
  65.         UnsignedFixedMulDiv(), SndGetInfo(), SndSetInfo(), GetSoundOutputInfo(),
  66.         SetSoundOutputInfo(), GetCompressionName(), SoundConverterOpen(),
  67.         SoundConverterClose(), SoundConverterGetBufferSizes(), SoundConverterBeginConversion(),
  68.         SoundConverterConvertBuffer(), SoundConverterEndConversion()
  69. */
  70. /*
  71.     Interfaces for Sound Driver, !!! OBSOLETE and NOT SUPPORTED !!!
  72.  
  73.     These items are no longer defined, but appear here so that someone
  74.     searching the interfaces might find them. If you are using one of these
  75.     items, you must change your code to support the Sound Manager.
  76.  
  77.         swMode, ftMode, ffMode
  78.         FreeWave, FFSynthRec, Tone, SWSynthRec, Wave, FTSoundRec
  79.         SndCompletionProcPtr
  80.         StartSound, StopSound, SoundDone
  81. */
  82.  
  83.  
  84. #define twelfthRootTwo            1.05946309435
  85. enum {
  86.     soundListRsrc                = 'snd ',                        /*Resource type used by Sound Manager*/
  87.     rate44khz                    = 0xAC440000L,                    /*44100.00000 in fixed-point*/
  88.     rate22050hz                    = 0x56220000L,                    /*22050.00000 in fixed-point*/
  89.     rate22khz                    = 0x56EE8BA3L,                    /*22254.54545 in fixed-point*/
  90.     rate11khz                    = 0x2B7745D1L,                    /*11127.27273 in fixed-point*/
  91.     rate11025hz                    = 0x2B110000,                    /*11025.00000 in fixed-point*/
  92. /*synthesizer numbers for SndNewChannel*/
  93.     squareWaveSynth                = 1,                            /*square wave synthesizer*/
  94.     waveTableSynth                = 3,                            /*wave table synthesizer*/
  95.     sampledSynth                = 5,                            /*sampled sound synthesizer*/
  96. /*old Sound Manager MACE synthesizer numbers*/
  97.     MACE3snthID                    = 11,
  98.     MACE6snthID                    = 13,
  99.     kMiddleC                    = 60,                            /*MIDI note value for middle C*/
  100.     kSimpleBeepID                = 1,                            /*reserved resource ID for Simple Beep*/
  101.     kFullVolume                    = 0x0100,                        /*1.0, setting for full hardware output volume*/
  102.     kNoVolume                    = 0,                            /*setting for no sound volume*/
  103. /*command numbers for SndDoCommand and SndDoImmediate*/
  104.     nullCmd                        = 0,
  105.     initCmd                        = 1,
  106.     freeCmd                        = 2,
  107.     quietCmd                    = 3,
  108.     flushCmd                    = 4,
  109.     reInitCmd                    = 5,
  110.     waitCmd                        = 10,
  111.     pauseCmd                    = 11,
  112.     resumeCmd                    = 12,
  113.     callBackCmd                    = 13
  114. };
  115.  
  116. enum {
  117.     syncCmd                        = 14,
  118.     availableCmd                = 24,
  119.     versionCmd                    = 25,
  120.     totalLoadCmd                = 26,
  121.     loadCmd                        = 27,
  122.     freqDurationCmd                = 40,
  123.     restCmd                        = 41,
  124.     freqCmd                        = 42,
  125.     ampCmd                        = 43,
  126.     timbreCmd                    = 44,
  127.     getAmpCmd                    = 45,
  128.     volumeCmd                    = 46,                            /*sound manager 3.0 or later only*/
  129.     getVolumeCmd                = 47,                            /*sound manager 3.0 or later only*/
  130.     waveTableCmd                = 60,
  131.     phaseCmd                    = 61
  132. };
  133.  
  134. enum {
  135.     soundCmd                    = 80,
  136.     bufferCmd                    = 81,
  137.     rateCmd                        = 82,
  138.     continueCmd                    = 83,
  139.     doubleBufferCmd                = 84,
  140.     getRateCmd                    = 85,
  141.     rateMultiplierCmd            = 86,
  142.     getRateMultiplierCmd        = 87,
  143.     sizeCmd                        = 90,                            /*obsolete command*/
  144.     convertCmd                    = 91,                            /*obsolete MACE command*/
  145.     stdQLength                    = 128,
  146.     dataOffsetFlag                = 0x8000
  147. };
  148.  
  149. /*channel initialization parameters*/
  150. #if OLDROUTINENAMES
  151. enum {
  152.     waveInitChannelMask            = 0x07,
  153.     waveInitChannel0            = 0x04,                            /*wave table only, Sound Manager 2.0 and earlier*/
  154.     waveInitChannel1            = 0x05,                            /*wave table only, Sound Manager 2.0 and earlier*/
  155.     waveInitChannel2            = 0x06,                            /*wave table only, Sound Manager 2.0 and earlier*/
  156.     waveInitChannel3            = 0x07,                            /*wave table only, Sound Manager 2.0 and earlier*/
  157.     initChan0                    = waveInitChannel0,                /*obsolete spelling*/
  158.     initChan1                    = waveInitChannel1,                /*obsolete spelling*/
  159.     initChan2                    = waveInitChannel2,                /*obsolete spelling*/
  160.     initChan3                    = waveInitChannel3                /*obsolete spelling*/
  161. };
  162.  
  163. #endif
  164. enum {
  165.     initChanLeft                = 0x0002,                        /*left stereo channel*/
  166.     initChanRight                = 0x0003,                        /*right stereo channel*/
  167.     initNoInterp                = 0x0004,                        /*no linear interpolation*/
  168.     initNoDrop                    = 0x0008,                        /*no drop-sample conversion*/
  169.     initMono                    = 0x0080,                        /*monophonic channel*/
  170.     initStereo                    = 0x00C0,                        /*stereo channel*/
  171.     initMACE3                    = 0x0300,                        /*MACE 3:1*/
  172.     initMACE6                    = 0x0400,                        /*MACE 6:1*/
  173.     initPanMask                    = 0x0003,                        /*mask for right/left pan values*/
  174.     initSRateMask                = 0x0030,                        /*mask for sample rate values*/
  175.     initStereoMask                = 0x00C0,                        /*mask for mono/stereo values*/
  176.     initCompMask                = 0xFF00,                        /*mask for compression IDs*/
  177.     kUseOptionalOutputDevice    = -1,                            /*only for Sound Manager 3.0 or later*/
  178.     notCompressed                = 0,                            /*compression ID's*/
  179.     fixedCompression            = -1,                            /*compression ID for fixed-sized compression*/
  180.     variableCompression            = -2,                            /*compression ID for variable-sized compression*/
  181.     twoToOne                    = 1,
  182.     eightToThree                = 2,
  183.     threeToOne                    = 3,
  184.     sixToOne                    = 4
  185. };
  186.  
  187. enum {
  188.     stdSH                        = 0x00,                            /*Standard sound header encode value*/
  189.     extSH                        = 0xFF,                            /*Extended sound header encode value*/
  190.     cmpSH                        = 0xFE                            /*Compressed sound header encode value*/
  191. };
  192.  
  193. enum {
  194.     outsideCmpSH                = 0,                            /*obsolete MACE constant*/
  195.     insideCmpSH                    = 1,                            /*obsolete MACE constant*/
  196.     aceSuccess                    = 0,                            /*obsolete MACE constant*/
  197.     aceMemFull                    = 1,                            /*obsolete MACE constant*/
  198.     aceNilBlock                    = 2,                            /*obsolete MACE constant*/
  199.     aceBadComp                    = 3,                            /*obsolete MACE constant*/
  200.     aceBadEncode                = 4,                            /*obsolete MACE constant*/
  201.     aceBadDest                    = 5,                            /*obsolete MACE constant*/
  202.     aceBadCmd                    = 6,                            /*obsolete MACE constant*/
  203.     sixToOnePacketSize            = 8,
  204.     threeToOnePacketSize        = 16,
  205.     stateBlockSize                = 64,
  206.     leftOverBlockSize            = 32,
  207.     firstSoundFormat            = 0x0001,                        /*general sound format*/
  208.     secondSoundFormat            = 0x0002,                        /*special sampled sound format (HyperCard)*/
  209.     dbBufferReady                = 0x00000001,                    /*double buffer is filled*/
  210.     dbLastBuffer                = 0x00000004,                    /*last double buffer to play*/
  211.     sysBeepDisable                = 0x0000,                        /*SysBeep() enable flags*/
  212.     sysBeepEnable                = (1 << 0),
  213.     sysBeepSynchronous            = (1 << 1),                        /*if bit set, make alert sounds synchronous*/
  214.     unitTypeNoSelection            = 0xFFFF,                        /*unitTypes for AudioSelection.unitType*/
  215.     unitTypeSeconds                = 0x0000
  216. };
  217.  
  218.  
  219.  
  220. /* unsigned fixed-point number */
  221. typedef unsigned long UnsignedFixed;
  222.  
  223. struct SndCommand {
  224.     unsigned short                    cmd;
  225.     short                            param1;
  226.     long                            param2;
  227. };
  228. typedef struct SndCommand SndCommand;
  229.  
  230. typedef struct SndChannel SndChannel;
  231.  
  232. typedef SndChannel *SndChannelPtr;
  233.  
  234. typedef pascal void (*SndCallBackProcPtr)(SndChannelPtr chan, SndCommand *cmd);
  235.  
  236. #if GENERATINGCFM
  237. typedef UniversalProcPtr SndCallBackUPP;
  238. #else
  239. typedef SndCallBackProcPtr SndCallBackUPP;
  240. #endif
  241.  
  242. struct SndChannel {
  243.     SndChannelPtr                    nextChan;
  244.     Ptr                                firstMod;                    /* reserved for the Sound Manager */
  245.     SndCallBackUPP                    callBack;
  246.     long                            userInfo;
  247.     long                            wait;                        /* The following is for internal Sound Manager use only.*/
  248.     SndCommand                        cmdInProgress;
  249.     short                            flags;
  250.     short                            qLength;
  251.     short                            qHead;
  252.     short                            qTail;
  253.     SndCommand                        queue[stdQLength];
  254. };
  255.  
  256.  
  257. /*MACE structures*/
  258. struct StateBlock {
  259.     short                            stateVar[stateBlockSize];
  260. };
  261. typedef struct StateBlock StateBlock;
  262.  
  263. typedef StateBlock *StateBlockPtr;
  264.  
  265. struct LeftOverBlock {
  266.     unsigned long                    count;
  267.     SInt8                            sampleArea[leftOverBlockSize];
  268. };
  269. typedef struct LeftOverBlock LeftOverBlock;
  270.  
  271. typedef LeftOverBlock *LeftOverBlockPtr;
  272.  
  273. struct ModRef {
  274.     unsigned short                    modNumber;
  275.     long                            modInit;
  276. };
  277. typedef struct ModRef ModRef;
  278.  
  279. struct SndListResource {
  280.     short                            format;
  281.     short                            numModifiers;
  282.     ModRef                            modifierPart[1];            /*This is a variable length array*/
  283.     short                            numCommands;
  284.     SndCommand                        commandPart[1];                /*This is a variable length array*/
  285.     UInt8                            dataPart[1];                /*This is a variable length array*/
  286. };
  287. typedef struct SndListResource SndListResource;
  288.  
  289. typedef SndListResource *SndListPtr;
  290.  
  291. typedef SndListPtr *SndListHndl, *SndListHandle;
  292.  
  293. /*HyperCard sound resource format*/
  294. struct Snd2ListResource {
  295.     short                            format;
  296.     short                            refCount;
  297.     short                            numCommands;
  298.     SndCommand                        commandPart[1];                /*This is a variable length array*/
  299.     UInt8                            dataPart[1];                /*This is a variable length array*/
  300. };
  301. typedef struct Snd2ListResource Snd2ListResource;
  302.  
  303. typedef Snd2ListResource *Snd2ListPtr;
  304.  
  305. typedef Snd2ListPtr *Snd2ListHndl, *Snd2ListHandle;
  306.  
  307. struct SoundHeader {
  308.     Ptr                                samplePtr;                    /*if NIL then samples are in sampleArea*/
  309.     unsigned long                    length;                        /*length of sound in bytes*/
  310.     UnsignedFixed                    sampleRate;                    /*sample rate for this sound*/
  311.     unsigned long                    loopStart;                    /*start of looping portion*/
  312.     unsigned long                    loopEnd;                    /*end of looping portion*/
  313.     UInt8                            encode;                        /*header encoding*/
  314.     UInt8                            baseFrequency;                /*baseFrequency value*/
  315.     UInt8                            sampleArea[1];                /*space for when samples follow directly*/
  316. };
  317. typedef struct SoundHeader SoundHeader;
  318.  
  319. typedef SoundHeader *SoundHeaderPtr;
  320.  
  321. struct CmpSoundHeader {
  322.     Ptr                                samplePtr;                    /*if nil then samples are in sample area*/
  323.     unsigned long                    numChannels;                /*number of channels i.e. mono = 1*/
  324.     UnsignedFixed                    sampleRate;                    /*sample rate in Apples Fixed point representation*/
  325.     unsigned long                    loopStart;                    /*loopStart of sound before compression*/
  326.     unsigned long                    loopEnd;                    /*loopEnd of sound before compression*/
  327.     UInt8                            encode;                        /*data structure used , stdSH, extSH, or cmpSH*/
  328.     UInt8                            baseFrequency;                /*same meaning as regular SoundHeader*/
  329.     unsigned long                    numFrames;                    /*length in frames ( packetFrames or sampleFrames )*/
  330.     extended80                        AIFFSampleRate;                /*IEEE sample rate*/
  331.     Ptr                                markerChunk;                /*sync track*/
  332.     OSType                            format;                        /*data format type, was futureUse1*/
  333.     unsigned long                    futureUse2;                    /*reserved by Apple*/
  334.     StateBlockPtr                    stateVars;                    /*pointer to State Block*/
  335.     LeftOverBlockPtr                leftOverSamples;            /*used to save truncated samples between compression calls*/
  336.     short                            compressionID;                /*0 means no compression, non zero means compressionID*/
  337.     unsigned short                    packetSize;                    /*number of bits in compressed sample packet*/
  338.     unsigned short                    snthID;                        /*resource ID of Sound Manager snth that contains NRT C/E*/
  339.     unsigned short                    sampleSize;                    /*number of bits in non-compressed sample*/
  340.     unsigned char                    sampleArea[1];                /*space for when samples follow directly*/
  341. };
  342. typedef struct CmpSoundHeader CmpSoundHeader;
  343.  
  344. typedef CmpSoundHeader *CmpSoundHeaderPtr;
  345.  
  346. struct ExtSoundHeader {
  347.     Ptr                                samplePtr;                    /*if nil then samples are in sample area*/
  348.     unsigned long                    numChannels;                /*number of channels,  ie mono = 1*/
  349.     UnsignedFixed                    sampleRate;                    /*sample rate in Apples Fixed point representation*/
  350.     unsigned long                    loopStart;                    /*same meaning as regular SoundHeader*/
  351.     unsigned long                    loopEnd;                    /*same meaning as regular SoundHeader*/
  352.     UInt8                            encode;                        /*data structure used , stdSH, extSH, or cmpSH*/
  353.     UInt8                            baseFrequency;                /*same meaning as regular SoundHeader*/
  354.     unsigned long                    numFrames;                    /*length in total number of frames*/
  355.     extended80                        AIFFSampleRate;                /*IEEE sample rate*/
  356.     Ptr                                markerChunk;                /*sync track*/
  357.     Ptr                                instrumentChunks;            /*AIFF instrument chunks*/
  358.     Ptr                                AESRecording;
  359.     unsigned short                    sampleSize;                    /*number of bits in sample*/
  360.     unsigned short                    futureUse1;                    /*reserved by Apple*/
  361.     unsigned long                    futureUse2;                    /*reserved by Apple*/
  362.     unsigned long                    futureUse3;                    /*reserved by Apple*/
  363.     unsigned long                    futureUse4;                    /*reserved by Apple*/
  364.     unsigned char                    sampleArea[1];                /*space for when samples follow directly*/
  365. };
  366. typedef struct ExtSoundHeader ExtSoundHeader;
  367.  
  368. typedef ExtSoundHeader *ExtSoundHeaderPtr;
  369.  
  370. struct ConversionBlock {
  371.     short                            destination;
  372.     short                            unused;
  373.     CmpSoundHeaderPtr                inputPtr;
  374.     CmpSoundHeaderPtr                outputPtr;
  375. };
  376. typedef struct ConversionBlock ConversionBlock;
  377.  
  378. typedef ConversionBlock *ConversionBlockPtr;
  379.  
  380. struct SMStatus {
  381.     short                            smMaxCPULoad;
  382.     short                            smNumChannels;
  383.     short                            smCurCPULoad;
  384. };
  385. typedef struct SMStatus SMStatus;
  386.  
  387. typedef SMStatus *SMStatusPtr;
  388.  
  389. struct SCStatus {
  390.     UnsignedFixed                    scStartTime;
  391.     UnsignedFixed                    scEndTime;
  392.     UnsignedFixed                    scCurrentTime;
  393.     Boolean                            scChannelBusy;
  394.     Boolean                            scChannelDisposed;
  395.     Boolean                            scChannelPaused;
  396.     Boolean                            scUnused;
  397.     unsigned long                    scChannelAttributes;
  398.     long                            scCPULoad;
  399. };
  400. typedef struct SCStatus SCStatus;
  401.  
  402. typedef SCStatus *SCStatusPtr;
  403.  
  404. struct AudioSelection {
  405.     long                            unitType;
  406.     UnsignedFixed                    selStart;
  407.     UnsignedFixed                    selEnd;
  408. };
  409. typedef pascal void (*FilePlayCompletionProcPtr)(SndChannelPtr chan);
  410.  
  411. #if GENERATINGCFM
  412. typedef UniversalProcPtr FilePlayCompletionUPP;
  413. #else
  414. typedef FilePlayCompletionProcPtr FilePlayCompletionUPP;
  415. #endif
  416.  
  417. enum {
  418.     uppFilePlayCompletionProcInfo = kPascalStackBased
  419.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SndChannelPtr)))
  420. };
  421.  
  422. #if GENERATINGCFM
  423. #define NewFilePlayCompletionProc(userRoutine)        \
  424.         (FilePlayCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFilePlayCompletionProcInfo, GetCurrentArchitecture())
  425. #else
  426. #define NewFilePlayCompletionProc(userRoutine)        \
  427.         ((FilePlayCompletionUPP) (userRoutine))
  428. #endif
  429.  
  430. #if GENERATINGCFM
  431. #define CallFilePlayCompletionProc(userRoutine, chan)        \
  432.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFilePlayCompletionProcInfo, (chan))
  433. #else
  434. #define CallFilePlayCompletionProc(userRoutine, chan)        \
  435.         (*(userRoutine))((chan))
  436. #endif
  437.  
  438. typedef struct AudioSelection AudioSelection;
  439.  
  440. typedef AudioSelection *AudioSelectionPtr;
  441.  
  442. struct SndDoubleBuffer {
  443.     long                            dbNumFrames;
  444.     long                            dbFlags;
  445.     long                            dbUserInfo[2];
  446.     char                            dbSoundData[1];
  447. };
  448. typedef struct SndDoubleBuffer SndDoubleBuffer;
  449.  
  450. typedef SndDoubleBuffer *SndDoubleBufferPtr;
  451.  
  452. typedef pascal void (*SndDoubleBackProcPtr)(SndChannelPtr channel, SndDoubleBufferPtr doubleBufferPtr);
  453.  
  454. #if GENERATINGCFM
  455. typedef UniversalProcPtr SndDoubleBackUPP;
  456. #else
  457. typedef SndDoubleBackProcPtr SndDoubleBackUPP;
  458. #endif
  459.  
  460. enum {
  461.     uppSndDoubleBackProcInfo = kPascalStackBased
  462.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SndChannelPtr)))
  463.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SndDoubleBufferPtr)))
  464. };
  465.  
  466. #if GENERATINGCFM
  467. #define NewSndDoubleBackProc(userRoutine)        \
  468.         (SndDoubleBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSndDoubleBackProcInfo, GetCurrentArchitecture())
  469. #else
  470. #define NewSndDoubleBackProc(userRoutine)        \
  471.         ((SndDoubleBackUPP) (userRoutine))
  472. #endif
  473.  
  474. #if GENERATINGCFM
  475. #define CallSndDoubleBackProc(userRoutine, channel, doubleBufferPtr)        \
  476.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSndDoubleBackProcInfo, (channel), (doubleBufferPtr))
  477. #else
  478. #define CallSndDoubleBackProc(userRoutine, channel, doubleBufferPtr)        \
  479.         (*(userRoutine))((channel), (doubleBufferPtr))
  480. #endif
  481.  
  482. struct SndDoubleBufferHeader {
  483.     short                            dbhNumChannels;
  484.     short                            dbhSampleSize;
  485.     short                            dbhCompressionID;
  486.     short                            dbhPacketSize;
  487.     UnsignedFixed                    dbhSampleRate;
  488.     SndDoubleBufferPtr                dbhBufferPtr[2];
  489.     SndDoubleBackUPP                dbhDoubleBack;
  490. };
  491. typedef struct SndDoubleBufferHeader SndDoubleBufferHeader;
  492.  
  493. typedef SndDoubleBufferHeader *SndDoubleBufferHeaderPtr;
  494.  
  495. struct SndDoubleBufferHeader2 {
  496.     short                            dbhNumChannels;
  497.     short                            dbhSampleSize;
  498.     short                            dbhCompressionID;
  499.     short                            dbhPacketSize;
  500.     UnsignedFixed                    dbhSampleRate;
  501.     SndDoubleBufferPtr                dbhBufferPtr[2];
  502.     SndDoubleBackUPP                dbhDoubleBack;
  503.     OSType                            dbhFormat;
  504. };
  505. typedef struct SndDoubleBufferHeader2 SndDoubleBufferHeader2;
  506.  
  507. typedef SndDoubleBufferHeader2 *SndDoubleBufferHeader2Ptr;
  508.  
  509. struct SoundInfoList {
  510.     short                            count;
  511.     Handle                            infoHandle;
  512. };
  513. typedef struct SoundInfoList SoundInfoList;
  514.  
  515. typedef SoundInfoList *SoundInfoListPtr;
  516.  
  517. struct SoundComponentData {
  518.     long                            flags;
  519.     OSType                            format;
  520.     short                            numChannels;
  521.     short                            sampleSize;
  522.     UnsignedFixed                    sampleRate;
  523.     long                            sampleCount;
  524.     Byte                            *buffer;
  525.     long                            reserved;
  526. };
  527. typedef struct SoundComponentData SoundComponentData;
  528.  
  529. typedef SoundComponentData *SoundComponentDataPtr;
  530.  
  531. struct CompressionInfo {
  532.     long                            recordSize;
  533.     OSType                            format;
  534.     short                            compressionID;
  535.     unsigned short                    samplesPerPacket;
  536.     unsigned short                    bytesPerPacket;
  537.     unsigned short                    bytesPerFrame;
  538.     unsigned short                    bytesPerSample;
  539.     unsigned short                    futureUse1;
  540. };
  541. typedef struct CompressionInfo CompressionInfo;
  542.  
  543. typedef CompressionInfo *CompressionInfoPtr;
  544.  
  545. typedef CompressionInfoPtr *CompressionInfoHandle;
  546.  
  547. typedef struct privateSoundConverter *SoundConverter;
  548.  
  549. /* These two routines for Get/SetSoundVol should no longer be used.*/
  550. /* They were for old Apple Sound Chip machines, and do not support the DSP or PowerMacs.*/
  551. /* Use Get/SetDefaultOutputVolume instead, if you must change the user's machine.*/
  552. #if OLDROUTINENAMES && !GENERATINGCFM
  553. extern pascal void SetSoundVol(short level);
  554.  
  555. #if !GENERATINGCFM
  556. #pragma parameter GetSoundVol(__A0)
  557. #endif
  558. extern pascal void GetSoundVol(short *level)
  559.  THREEWORDINLINE(0x4218, 0x10B8, 0x0260);
  560. #endif
  561.  
  562.  
  563. extern pascal OSErr SndDoCommand(SndChannelPtr chan, const SndCommand *cmd, Boolean noWait)
  564.  ONEWORDINLINE(0xA803);
  565. extern pascal OSErr SndDoImmediate(SndChannelPtr chan, const SndCommand *cmd)
  566.  ONEWORDINLINE(0xA804);
  567. extern pascal OSErr SndNewChannel(SndChannelPtr *chan, short synth, long init, SndCallBackUPP userRoutine)
  568.  ONEWORDINLINE(0xA807);
  569. extern pascal OSErr SndDisposeChannel(SndChannelPtr chan, Boolean quietNow)
  570.  ONEWORDINLINE(0xA801);
  571. extern pascal OSErr SndPlay(SndChannelPtr chan, SndListHandle sndHandle, Boolean async)
  572.  ONEWORDINLINE(0xA805);
  573. #if OLDROUTINENAMES
  574. extern pascal OSErr SndAddModifier(SndChannelPtr chan, Ptr modifier, short id, long init)
  575.  ONEWORDINLINE(0xA802);
  576. #endif
  577. extern pascal OSErr SndControl(short id, SndCommand *cmd)
  578.  ONEWORDINLINE(0xA806);
  579.  
  580.  
  581. /* Sound Manager 2.0 and later, uses _SoundDispatch */
  582. extern pascal NumVersion SndSoundManagerVersion(void)
  583.  FOURWORDINLINE(0x203C, 0x000C, 0x0008, 0xA800);
  584. extern pascal OSErr SndStartFilePlay(SndChannelPtr chan, short fRefNum, short resNum, long bufferSize, void *theBuffer, AudioSelectionPtr theSelection, FilePlayCompletionUPP theCompletion, Boolean async)
  585.  FOURWORDINLINE(0x203C, 0x0D00, 0x0008, 0xA800);
  586. extern pascal OSErr SndPauseFilePlay(SndChannelPtr chan)
  587.  FOURWORDINLINE(0x203C, 0x0204, 0x0008, 0xA800);
  588. extern pascal OSErr SndStopFilePlay(SndChannelPtr chan, Boolean quietNow)
  589.  FOURWORDINLINE(0x203C, 0x0308, 0x0008, 0xA800);
  590. extern pascal OSErr SndChannelStatus(SndChannelPtr chan, short theLength, SCStatusPtr theStatus)
  591.  FOURWORDINLINE(0x203C, 0x0510, 0x0008, 0xA800);
  592. extern pascal OSErr SndManagerStatus(short theLength, SMStatusPtr theStatus)
  593.  FOURWORDINLINE(0x203C, 0x0314, 0x0008, 0xA800);
  594. extern pascal void SndGetSysBeepState(short *sysBeepState)
  595.  FOURWORDINLINE(0x203C, 0x0218, 0x0008, 0xA800);
  596. extern pascal OSErr SndSetSysBeepState(short sysBeepState)
  597.  FOURWORDINLINE(0x203C, 0x011C, 0x0008, 0xA800);
  598. extern pascal OSErr SndPlayDoubleBuffer(SndChannelPtr chan, SndDoubleBufferHeaderPtr theParams)
  599.  FOURWORDINLINE(0x203C, 0x0420, 0x0008, 0xA800);
  600.  
  601.  
  602. /* MACE compression routines */
  603. extern pascal NumVersion MACEVersion(void)
  604.  FOURWORDINLINE(0x203C, 0x0000, 0x0010, 0xA800);
  605. extern pascal void Comp3to1(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  606.  FOURWORDINLINE(0x203C, 0x0004, 0x0010, 0xA800);
  607. extern pascal void Exp1to3(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  608.  FOURWORDINLINE(0x203C, 0x0008, 0x0010, 0xA800);
  609. extern pascal void Comp6to1(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  610.  FOURWORDINLINE(0x203C, 0x000C, 0x0010, 0xA800);
  611. extern pascal void Exp1to6(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  612.  FOURWORDINLINE(0x203C, 0x0010, 0x0010, 0xA800);
  613.  
  614.  
  615. /* Sound Manager 3.0 and later calls */
  616. extern pascal OSErr GetSysBeepVolume(long *level)
  617.  FOURWORDINLINE(0x203C, 0x0224, 0x0018, 0xA800);
  618. extern pascal OSErr SetSysBeepVolume(long level)
  619.  FOURWORDINLINE(0x203C, 0x0228, 0x0018, 0xA800);
  620. extern pascal OSErr GetDefaultOutputVolume(long *level)
  621.  FOURWORDINLINE(0x203C, 0x022C, 0x0018, 0xA800);
  622. extern pascal OSErr SetDefaultOutputVolume(long level)
  623.  FOURWORDINLINE(0x203C, 0x0230, 0x0018, 0xA800);
  624. extern pascal OSErr GetSoundHeaderOffset(SndListHandle sndHandle, long *offset)
  625.  FOURWORDINLINE(0x203C, 0x0404, 0x0018, 0xA800);
  626. extern pascal UnsignedFixed UnsignedFixedMulDiv(UnsignedFixed value, UnsignedFixed multiplier, UnsignedFixed divisor)
  627.  FOURWORDINLINE(0x203C, 0x060C, 0x0018, 0xA800);
  628. extern pascal OSErr GetCompressionInfo(short compressionID, OSType format, short numChannels, short sampleSize, CompressionInfoPtr cp)
  629.  FOURWORDINLINE(0x203C, 0x0710, 0x0018, 0xA800);
  630. extern pascal OSErr SetSoundPreference(OSType theType, Str255 name, Handle settings)
  631.  FOURWORDINLINE(0x203C, 0x0634, 0x0018, 0xA800);
  632. extern pascal OSErr GetSoundPreference(OSType theType, Str255 name, Handle settings)
  633.  FOURWORDINLINE(0x203C, 0x0638, 0x0018, 0xA800);
  634.  
  635.  
  636. /* Sound Manager 3.1 and later calls */
  637. extern pascal OSErr SndGetInfo(SndChannelPtr chan, OSType selector, void *infoPtr)
  638.  FOURWORDINLINE(0x203C, 0x063C, 0x0018, 0xA800);
  639. extern pascal OSErr SndSetInfo(SndChannelPtr chan, OSType selector, const void *infoPtr)
  640.  FOURWORDINLINE(0x203C, 0x0640, 0x0018, 0xA800);
  641. extern pascal OSErr GetSoundOutputInfo(Component outputDevice, OSType selector, void *infoPtr)
  642.  FOURWORDINLINE(0x203C, 0x0644, 0x0018, 0xA800);
  643. extern pascal OSErr SetSoundOutputInfo(Component outputDevice, OSType selector, const void *infoPtr)
  644.  FOURWORDINLINE(0x203C, 0x0648, 0x0018, 0xA800);
  645.  
  646.  
  647. /* Sound Manager 3.2 and later calls */
  648. extern pascal OSErr GetCompressionName(OSType compressionType, Str255 compressionName)
  649.  FOURWORDINLINE(0x203C, 0x044C, 0x0018, 0xA800);
  650. extern pascal OSErr SoundConverterOpen(const SoundComponentData *inputFormat, const SoundComponentData *outputFormat, SoundConverter *sc)
  651.  FOURWORDINLINE(0x203C, 0x0650, 0x0018, 0xA800);
  652. extern pascal OSErr SoundConverterClose(SoundConverter sc)
  653.  FOURWORDINLINE(0x203C, 0x0254, 0x0018, 0xA800);
  654. extern pascal OSErr SoundConverterGetBufferSizes(SoundConverter sc, unsigned long inputBytesTarget, unsigned long *inputFrames, unsigned long *inputBytes, unsigned long *outputBytes)
  655.  FOURWORDINLINE(0x203C, 0x0A58, 0x0018, 0xA800);
  656. extern pascal OSErr SoundConverterBeginConversion(SoundConverter sc)
  657.  FOURWORDINLINE(0x203C, 0x025C, 0x0018, 0xA800);
  658. extern pascal OSErr SoundConverterConvertBuffer(SoundConverter sc, const void *inputPtr, unsigned long inputFrames, void *outputPtr, unsigned long *outputFrames, unsigned long *outputBytes)
  659.  FOURWORDINLINE(0x203C, 0x0C60, 0x0018, 0xA800);
  660. extern pascal OSErr SoundConverterEndConversion(SoundConverter sc, void *outputPtr, unsigned long *outputFrames, unsigned long *outputBytes)
  661.  FOURWORDINLINE(0x203C, 0x0864, 0x0018, 0xA800);
  662. enum {
  663.     uppSndCallBackProcInfo = kPascalStackBased
  664.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SndChannelPtr)))
  665.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SndCommand*)))
  666. };
  667.  
  668. #if GENERATINGCFM
  669. #define NewSndCallBackProc(userRoutine)        \
  670.         (SndCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSndCallBackProcInfo, GetCurrentArchitecture())
  671. #else
  672. #define NewSndCallBackProc(userRoutine)        \
  673.         ((SndCallBackUPP) (userRoutine))
  674. #endif
  675.  
  676. #if GENERATINGCFM
  677. #define CallSndCallBackProc(userRoutine, chan, cmd)        \
  678.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSndCallBackProcInfo, (chan), (cmd))
  679. #else
  680. #define CallSndCallBackProc(userRoutine, chan, cmd)        \
  681.         (*(userRoutine))((chan), (cmd))
  682. #endif
  683.  
  684.  
  685. #if PRAGMA_IMPORT_SUPPORTED
  686. #pragma import off
  687. #endif
  688.  
  689. #if PRAGMA_ALIGN_SUPPORTED
  690. #pragma options align=reset
  691. #endif
  692.  
  693. #ifdef __cplusplus
  694. }
  695. #endif
  696.  
  697. #endif /* __SOUND__ */
  698.